/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package 垃.圾;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import z.h.w.jar.kit.method.Num;
import z.h.w.jar.kit.method.Roll;
import z.h.w.jar.kit.clazz.Split;
import z.h.w.jar.kit.method.To;
import z.h.w.jar.kit.clazz.security.GyrateCode;
import z.h.w.jar.kit.clazz.security.OffsetCode;

/**
 *
 * @author EnzoZhong
 */
public class ListTest {

      /**
       * @param args the command line arguments
       */
      public static void main ( String[] args ) {

            String string = Roll.range ( '0' , 'z' );

            GyrateCode gc = GyrateCode.born ();
            OffsetCode oc = OffsetCode.born ();

            String code = gc.加密 ( string , 3 );
            code = oc.加密 ( code );
            System.out.println ( code );
            System.out.println ( "" );
            code = oc.解密 ( code );
            System.out.println ( gc.解密 ( code , 1 ) );

      }

      public static Integer miniSquare ( Integer x ) {
            while (  ! Num.isInteger ( Math.sqrt ( x ) ) ) {
                  x ++;
            }
            return x;
      }

      public static List< List<Character>> dd ( String text ) {
            Integer len = text.length ();
            Double d = Math.sqrt ( Double.valueOf ( len ) );
            Integer tmp = d.intValue ();
            return dd ( text , tmp );
      }

      public static List< List<Character>> dd ( String text , Integer sp ) {
            Integer len = text.length ();
            List<Character> arrayList = Arrays.asList ( To.string2CharacterArray ( text ) );
            Split<Character> split = new Split<> ( arrayList , sp );
            List<Character> tempList;
            List< List<Character>> finalList = new ArrayList<> ( ( len / sp ) + 1 );
            while ( split.hasNext () ) {
                  tempList = split.next ();
                  List<Character> putList = new ArrayList<> ( ( len / sp ) + 1 );
                  for ( Character ch : tempList ) {
                        putList.add ( ch );
                  }
                  finalList.add ( putList );
            }
            return finalList;
      }

      public static Character[][] change ( List< List<Character>> input ) {
            Integer rowLen = input.size ();
            Integer columnLen = input.get ( 0 ).size ();

            Character[][] re = new Character[ rowLen ][ columnLen ];
            for ( Integer x = 0 ; x < rowLen ; x ++ ) {
                  for ( Integer y = 0 ; y <= columnLen - 1 ; y ++ ) {
                        try {
                              re[x][y] = input.get ( x ).get ( y );
                        } catch ( Exception e ) {
                        }
                  }
            }
            return re;
      }

      public static Character[][] turnRight ( Character[][] input ) {
            Character[][] temp = input.clone ();
            Integer lenH = temp.length;
            Integer lenL = temp[0].length;

            Integer indexL = 0;
            Integer indexH = lenH;

            Character[][] newArray = new Character[ lenL ][ lenH ];
            for ( Integer x = 0 ; x < lenL ; x ++ ) {
                  indexH = lenH - 1;
                  for ( Integer y = 0 ; y < lenH ; y ++ ) {
                        newArray[x][y] = temp[indexH][indexL] == null ? ' ' : temp[indexH][indexL];
                        indexH --;
                  }
                  indexL ++;
            }
            return newArray;
      }

      public static String array2String ( Character[][] input ) {
            StringBuffer stringBuffer = new StringBuffer ();
            Character[][] temp = input.clone ();
            for ( Integer x = 0 ; x < temp.length ; x ++ ) {
                  for ( Integer y = 0 ; y < input[x].length ; y ++ ) {
                        stringBuffer.append ( input[x][y] );
                  }
            }
            return stringBuffer.toString ();
      }

      public static void show ( Character[][] input ) {
            Character[][] temp = input.clone ();
            for ( Integer x = 0 ; x < temp.length ; x ++ ) {
                  for ( Integer y = 0 ; y < input[x].length ; y ++ ) {
                        System.out.print ( input[x][y] + " " );
                  }
                  System.out.println ( "" );
            }

      }

}
